import {
  GET_SONG_URL_SUCCESS,
  ISongUrl,
  SongUrlUnionType,
} from "../actions/songurl.action";

const initialState: ISongUrl | {} = {};

export default function songUrlReducer(
  state = initialState,
  action: SongUrlUnionType
) {
  switch (action.type) {
    case GET_SONG_URL_SUCCESS:
      if (action.payload.data.length > 0) {
        return action.payload.data[0];
      } else {
        return state;
      }
    default:
      return state;
  }
}
